<div class="layui-form" lay-filter="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">登录名</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="username" value="{{ d.params.username || '' }}" lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="userpass" value="{{ d.params.userpass || '' }}" lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="truename" value="{{ d.params.truename || '' }}" lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="userphone" value="{{ d.params.userphone || '' }}" lay-verify="phone" placeholder="请输入号码" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-upload">
        <label class="layui-form-label">头像</label>
        <div class="layui-upload-list">
            <script type="text/html" template>
                <img class="layui-upload-img" style="width:100px;height:100px" src="{{ d.params.usericon || '' }}" :style="test" id="demo1">
                <input type="hidden" name="usericon" value="{{ d.params.usericon || '' }}" lay-verify="required" autocomplete="off" class="layui-input"> 
                {{# var $ = layui.$ }}
                 {{# if(d.params.usericon ==''){ }}
                  {{# console.log(document.getElementById("demo1"))}}
                {{# console.log(d.params.usericon)}}
                 {{# console.log("111")}} {{# }else{ }} 
                 {{# console.log(d.params.usericon) }} {{# } }}

            </script>
            <button type="button" class="layui-btn" id="layuiadmin-upload-useradmin">上传图片</button>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">角色</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <select name="role">
          <option value="0" {{ d.params.role === '管理员' ? 'selected' : '' }}>管理员</option>
          <option value="1" {{ d.params.role === '超级管理员' ? 'selected' : '' }}>超级管理员</option>
          <option value="2" {{ d.params.role === '纠错员' ? 'selected' : '' }}>纠错员</option>
          <option value="3" {{ d.params.role === '采购员' ? 'selec+ted' : '' }}>采购员</option>
          <option value="4" {{ d.params.role === '推销员' ? 'selected' : '' }}>推销员</option>
          <option value="5" {{ d.params.role === '运营人员' ? 'selected' : '' }}>运营人员</option>
          <option value="6" {{ d.params.role === '编辑' ? 'selected' : '' }}>编辑</option>
        </select>
            </script>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-inline">
            <input type="button" lay-submit lay-filter="LAY-user-back-submit" value="确认" class="layui-btn">
        </div>
    </div>
</div>

<script>
    layui.use(['admin', 'form', 'upload', 'setter'], function() {
        var $ = layui.$,
            form = layui.form,
            setter = layui.setter,
            upload = layui.upload;

        //上传头像
        upload.render({
            elem: '#layuiadmin-upload-useradmin',
            url: setter.request.baseUrl + 'upload/uploadImg',
            accept: 'images',
            method: 'get',
            acceptMime: 'image/*',
            before: function(obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result) {
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            },
            done: function(res) {
                $(this.item).prev("div").children("input").val(res.path)
                $("#img-intsance").attr("src", res.path);
                form.val("layuiadmin-form-admin", { //formTest 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
                    "usericon": res.path
                });
            }
        });
    });
</script>